# Author:wyq
# 参数组

# * 后是参数组变量，变量名随意，取出的数是放在元组中。 args 接收N个位置参数
def test(*args):
    print(args)

test(123,2,34,5,6,7,8,2,1)
# args = tuple([1,2,3,4,5,6,7])
test(*[1,2,3,4,5,6,7])


def test2(x,*args):
    print('这是test2',x,args)
test2(1,2,2,3,45,6,6,7,7)

# 接收字典 **kwargs 把关键字参数转换成字典的格式，关键参数类似键值对
def test3(**kwargs):
    print(kwargs)
    print(kwargs['name'])

test3(name='aaa',age=8,sex='f')
test3(**{'name':'aaa','age':8,'sex':'f'})

#参数组一定要放在后面
def test4(name,age=18,**kwargs):
    print(name)
    print(age)
    print(kwargs)
test4('wang')
test4('wang',age=8,sex='男')

def logger(source):
    print("from %s"% source)

def test5(name,age=18,*args,**kwargs):
    print(name)
    print(age)
    print(args)
    print(kwargs)
    logger("test5")
# 这样不行
# test5('wang',age=8,13,2,4,5,sex='男')
test5('wang',8,13,2,4,5,sex='男')

